'''
Created on 2011-09-07

@author: kacper
'''
import unittest
from parsing.parser import sents_parse_string
from dataStructs.unify import unify
from dataStructs.definitions import Const, NotFormula, Relation, Var
from dataStructs.exceptions import UnificationError


class Test(unittest.TestCase):


    def setUp(self):
        self.constA = Const("a");
        

    def tearDown(self):
        pass


    def testSameConst(self):
        
        substs = []
        unify(self.constA, self.constA, substs)
        self.assertTrue(substs==[])

    def testSameConstNot(self):
        t1 = NotFormula(self.constA);
        substs = []
        unify(t1, t1, substs)
        self.assertTrue(substs==[])

    def testSameRelation(self):
        t1 = Relation([self.constA,self.constA])
        substs = []
        unify(t1, t1, substs)
        self.assertTrue(substs==[])

    def testsNoVar(self):
        t1 = Var("a")
        self.assertRaises(UnificationError,unify, t1,t1, [])
        
    def testsNonUniConst(self):
        t1 = Const("C")
        self.assertRaises(UnificationError,unify, t1,self.constA, [])
        
    def testNonUnifyRel(self):
        t1 = Relation([self.constA,self.constA])
        t2 = Relation([Const("C"),self.constA])
        self.assertRaises(UnificationError,unify, t1,t2, [])
        
            
    def testNonUnifyNot(self):
        t1 = NotFormula(self.constA);
        t2 = NotFormula(Const("C"));
        
        self.assertRaises(UnificationError,unify, t1,t2, [])
        

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testSame']
    unittest.main()